<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<meta name="csrf-token" content="{{ csrf_token() }}">
		<title>币种设置</title>
		<link rel="stylesheet" type="text/css" href="css/base.css" />
		<link rel="stylesheet" type="text/css" href="css/mui.min.css" />
		<link rel="stylesheet" type="text/css" href="css/public.css" />
		<link rel="stylesheet" type="text/css" href="css/currency-setting.css" />
		<script src="js/flexible.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/mui.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/gVerify.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/jquery-3.1.1.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
		<header class="mui-bar mui-bar-nav">
			<a href="my" class="mui-icon mui-icon-left-nav mui-pull-left" style="color: #000;"></a>
			<h1 class="mui-title">币种设置</h1>
		</header>
		<form id="form" action="currSet" method="post">
		<div class="content">
			<div class="flexStart settSelect">
				<span>选择交易所：</span>
				<select name="ex_id" id="ex">
					<option value="">请选择交易所</option>
					@foreach($list as $v)
						<option value="{{ $v->ex_id }}">{{ $v->name }}</option>
					@endforeach
				</select>
			</div>
			<div class="flexStart settSelect">
				<span>选择币种：</span>
				<select name="coin_name" id="curr">
				</select>
			</div>
			<div class="flexStart settSelect">
				<span>选择账户：</span>
				<select name="account_id" id="acc">
				</select>
			</div>
			<h4>设置比例</h4>
			<ul class="proportion">
				<li class="flexStart proportionIn">
					<span>参数1：</span>
					<input type="text" name="param1" id="param1" value="" />
				</li>
				<li class="flexStart proportionIn">
					<span>参数2：</span>
					<input type="text" name="param2" id="param2 value="" />
				</li>
				<li class="flexStart proportionIn">
					<span>参数3：</span>
					<input type="text" name="param3" id="param3" value="" />
				</li>
				<li class="flexStart proportionIn">
					<span>参数4：</span>
					<input type="text" name="param4" id="param4" value="" />
				</li>
				<li class="flexStart proportionIn">
					<span>参数5：</span>
					<input type="text" name="param5" id="param5" value="" />
				</li>
				<li class="flexStart proportionIn">
					<span>参数6：</span>
					<input type="text" name="param6" id="param6" value="" />
				</li>
				<li class="flexStart proportionIn">
					<span>参数7：</span>
					<input type="text" name="param7" id="param7" value="" />
				</li>
				<li class="flexStart proportionIn">
					<span>参数8：</span>
					<input type="text" name="param8" id="param8" value="" />
				</li>
				<li class="flexStart proportionIn">
					<span>保本比例：</span>
					<input type="text" name="param9" id="param9" value="" />
				</li>
				<li class="flexStart proportionIn">
					<span>最小交易限额：</span>
					<input type="text" name="param10" id="param10" value="" />
				</li>
				<li class="flexStart proportionIn">
					<span>降价卖出比例：</span>
					<input type="text" name="param11" id="param11" value="" />
				</li>
				<li class="flexStart proportionY">
					<span>验证码：</span>
					<input type="text" name="yzm" id="" value="" />
					<button type="button" id="yzm">发送验证码</button>
				</li>
				<li class="proportionIn"><button type="button" id="sub">保存</button></li>
			</ul>
		</div>
		</form>
		<div class="navBottom flexStart">
			<a class="navBottomB" href="exchange.html">交易记录</a>
			<a class="navBottomA" href="my">我的</a>
		</div>
	</body>
<script>
    $.ajaxSetup({
        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        }
    });
	$('#ex').change(function(){
        var ex=$('#ex').val();
        $.ajaxSettings.async=false;
        $.post('selectCurr',{ex_id:ex},function(e){
            var html='<option value="">请选择币种</option>';
            $.each(e.data,function(k,v){
                html+='<option value="'+v+'">'+v+'</option>';
            });
            $('#curr').html(html);
        });
        $.post('selUsername',{ex_id:ex},function(e){
            var html='<option value="">请选择账号</option>';
            $.each(e.data,function(k,v){
                html+='<option value="'+v.id+'">'+v.username+'</option>';
            });
            $('#acc').html(html);
        });
	});
	$('#acc').change(function(){
	    var coin_name=$('#curr').val();
	    var account_id=$('#acc').val();
	    $.post('configParam',{ex_id:ex,coin_name:coin_name,account_id:account_id},function(e){
	        for(var i=1;i<12;i++){
	            $('#param'+i).val(e.data.param+i);
			}
		})
	});
	var phone='{{ $phone }}';
	$('#yzm').click(function(){
	    $.post('my_send',{phone:phone},function(e){
            if(e.substring(7,8)==0){
                alert('发送成功');
            }else{
                alert('发送失败');
            };
		})
	});

	//提交表单
	$('#sub').click(function(){
		$.ajax({
			url:'currSet',
			type:'POST',
			data:$('#form').serialize(),
			dataType:'json',
			success:function(e){
				if(e.status>0){
					alert(e.msg)
				}else{
					alert(e.msg);

				}
			}
		})
	})
</script>
</html>
